package com.diaohaiwen.common.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * @author 刁海文
 * @since 2023/6/29 20:43
 * @Remark 权限路由配置
 */
@Data
@Component
@Configuration
@ConfigurationProperties(prefix = "setting.authority")
@EnableConfigurationProperties
public class AuthorityConfig {

    /**
     * 包含的路径
     */
    private String[] pathPatterns;

    /**
     * 排除的路径
     */
    private String[] excludePathPatterns;

    public String[] getPathPatterns() {
        if (pathPatterns == null) {
            return new String[]{"/**"};
        }
        return pathPatterns;
    }

    public String[] getExcludePathPatterns() {
        if (excludePathPatterns == null) {
            return new String[0];
        }
        return excludePathPatterns;
    }
}
